home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
025a
/
isamto.zip
/
ISAMTOOT.DOC
< prev
next >
Wrap
Text File
|
1991-11-05
|
11KB
|
267 lines
┌───────────────────────────────────────────────────────────────┐
│ ISAMTOOT - WORKBOOK NOTES │
└───────────────────────────────────────────────────────────────┘
GENERAL
You need to have Microsoft's BASIC Professional Development System
7.0 or higher. If when you installed PDS you didn't elect to
install the ISAM "option" then you should re-run your installation
to include it.
To avoid confusion we have deliberately avoided including any of
the excellent libraries MS furnishes with PDS. They ARE useful and
important tools -- particularly in the later lessons -- but our
judgement was that we wanted to focus on ISAM rather than expanding
the study to the libraries as well.
We have also included some "bad" programming practices in the
interests of simplicity and clarity. (i.e., getting data with the
LINE INPUT function.) We've noted these "flaws" as we create them
and you should flag them for further study and resolution -- again,
our focus is ISAM, not programming in general.
ISAMTOOT was developed in PDS 7.1 on a system that accepted MS's
"default" installation directories and sub directory structure(s).
When we call for a "DOS prompt" entry of -- say -- \bc7\bin\qbx, we
are intending to start the PDS environment AND to be in the
directory with QBX.EXE, etc.
Technical support for this instructional course is available on
CompuServe @ 70146,51, FAX: 817-488-4945, or 817-488-4940. The
telephones are answered 24 hours a day, 7 days a week.
LESSON #1
OBJECTIVE: Create, dimension, open and add data to a bare
bones ISAM database.
MS FILES NEEDED: QBX.EXE, PROISAMD.EXE (Please note that we
are using the larger of the two TSR's MS furnishes -
PROISAMD.EXE, rather than PROISAM.EXE
Comment: The smaller of the TSR's does save
some memory, but you can't create indexes with
it and more importantly, the various utilities
MS furnishes to repair and pack database files
need to have PROISAMD.EXE rather than
PROISAM.EXE. Certainly any commercial
application should use the "full featured"
version.
TO START: At the DOS prompt, type: PROISAMD and then press
your ENTER key. Your system will display the message:
"PROISAM successfully installed."
(If you are continuing an adjourned lesson,
then the message might be: "PROISAM already
installed." To remove PROISAMD from memory
you should type (at the DOS prompt): PROISAMD
/D and press the ENTER key.)
Now type: QBX and press the ENTER key. The screen should
clear and you find yourself in the programming
editor/environment.
Step #1. Type DEFINT A-Z and touch ENTER.
Step #2. Touch an apostrophe ' (to make this next line a
comment) and do a line of dashes. ( - )
Step #3. Touch an apostrophe: ' and type: ISAMTOOT.L1
You are correct in thinking that this file you are
creating -- the source code for lesson 1 -- would,
in the normal course of events have the extension:
.BAS. We have opted for this extension to maintain
uniformity within the course and avoid possible
damage of your other source code files.
Step #4. Another apostrophe and another line of dashes.
Step #5. Touch ENTER again to insert a blank line and then type:
CLS. (The first executable line of your program,
clearing the screen.)
Step #6. Another blank line, then type: TYPE lesson1data
We are beginning the actual defining of our first,
bare bones, database. Don't be stingy with blank
lines, spaces, indenting, comments. They cost you
nothing in a compiled program and the small
overhead they create within the environment is more
than paid back in clarity and ease of reading.
Step #7. Define three fields -- all strings, all 35 characters
long. The first is for the name, the second for the
address and the third for the city state and zip.
Step #8. Type END TYPE
Your finished definition block should look like:
TYPE
name AS STRING * 35
address AS STRING * 35
cityStateZip AS STRING * 35
END TYPE
(Perfectly all right to peek at the ISAMTOOT.L1 source
code. As a matter of fact, even though it is
considerably larger than the one you are writing, it will
run if you load it into QBX and do Shift+F5.)
Step #9. Now we dimension a variable for the lesson 1 data.
Type:
DIM lesson1record AS lesson1data
Step #10. Now we actually open the database and table . . .
OPEN "lesson1.MDB" FOR ISAM lesson1data "lesson1table"_
AS #1
(Please note that this is entered in a single line of
code. The underscore: _ is used to indicate that the
two lines are actually one.)
Step #11. We skip creation of an index for this first lesson, we'll
let ISAM use the one it creates when it adds records --
the null index. It is automatically selected when none
other is specified.
The database is now ready to receive some data, so we'll
set up a loop to gather information from the operator.
Step #12. Type in the following structure:
DO
CLS
PRINT , , "There are "; LOF(1); " records in _
the file."
PRINT
PRINT , : LINE INPUT "First & Last Name: ";_
lesson1record.name
PRINT , : LINE INPUT " Address: ";_
lesson1record.address
PRINT , : LINE INPUT "City, State & Zip: ";_
lesson1record.cityStateZip
PRINT
PRINT , "<S>ave - <E>dit - <Q>uit"
PRINT , " Touch S or E or Q"
dataDecision$ = UCASE$(INPUT$(1))
IF dataDecision$ = "S" THEN
INSERT #1, lesson1record
LOCATE 25, 40: PRINT " Saved ";
SLEEP 1
EXIT DO
END IF
LOOP UNTIL dataDecision$ = "Q"
Step #13. That structure is about as rudimentary as you can get.
LINE INPUT is not a good way to get data into a program
because the operator can enter anything, up to 32,000+
bytes, and doesn't return control to the program until
they press ENTER. It serves our purposes here, but
invites trouble in anything other than an "author-
operated" situation.
It's no fun to enter data unless you can see the "fruits
of your labor," so, to wrap up lesson one, lets take a
look at what we've entered in the database.
Step #14. Let's clear the screen and then write another loop to
look at our data . . .
CLS
PRINT
PRINT , "Total records now in the file: "; LOF(1)
PRINT
PRINT , "Now, we report the contents of the file . . . "
PRINT
MOVEFIRST #1
DO UNTIL EOF(1)
RETRIEVE #1, lesson1record
PRINT , lesson1record.name
PRINT , lesson1record.address
PRINT , lesson1record.cityStateZip
PRINT , "------------------------------------------"
SLEEP 1
MOVENEXT #1
LOOP
Step #15. This will display all the records in the database and
then the program will end. With Shift+F5, you can re-
start the program (it will show the number of records in
the file), enter another record, save it and then it will
fall through this "reporting loop" to show you everything
you've entered. Again stopping after reporting all the
records.
Polishing things up a bit would mean you would type in
the following . . .
PRINT
PRINT , "We've reached the end of the file."
PRINT
PRINT , "Press Shift+F5 to restart, enter a"
PRINT , "record and report file contents."
PRINT
PRINT
END
SUMMARIZING THE LESSON: You created and added records to an ISAM
database. While rudimentary, the program
you wrote will, in fact, manage data for
you.
If you substitute LPRINT statements for
the PRINT statements in the "reporting
loop" you can get hard copy of your data.
LOOKING AHEAD To be really useful, your database needs
to become more intricate. As it stands
now you wouldn't be able to sort to last
name or city or even zip code (as the
post office requires for bulk mailings.)
In Lesson #2, we will correct those
shortcomings AND we will be adding
INDEXES so that you can order your data
in more useful ways.
This lesson will seem very much like "See
Spot run." by the time you are managing
tables of 15-20 fields each and then
relating (as in relational database) the
data in distinctively different tables.
Just keep your dial set right here!
EDITOR'S NOTE: The file: ISAMTOOT.ENR has complete pricing
information for the full ten (10) lesson tutorial on ISAM. The
course is offered with an unusual money back guarantee of
satisfaction: If you are not delighted with the Course, just
return the materials for a prompt, no hassle refund.
Entire Contents Copyright 1991, Kirk Woodward d/b/a People Centered
Programs, PO Box 610171, Dallas, TX 75261-0171. CompuServe
70146,51 . Enrollments ONLY: 1-800-553-5883 . FAX: 817-488-4945
Voice: 817-488-4940
isamtoot.doc = wp51 /isamdoc.asc = ASCII